import {ActivatedRouteSnapshot, Resolve} from "@angular/router";
import {Injectable} from "@angular/core";
import * as API from "@api/index";
import {AuthService} from "@shared/service/auth/auth.service";
import {HttpService} from "@core/http/http.service";
import {Observable} from "rxjs/Observable";
import {SNSResult, UserInfoVO} from "@interface/index";


@Injectable()
export class MineResolver implements Resolve<any> {
  constructor(
    private authService: AuthService,
    private httpService: HttpService
  ) {}

  resolve(route: ActivatedRouteSnapshot): Observable<SNSResult<UserInfoVO>> {
    const url = `${API.USER_INFO}?userId=${this.authService.getUserId()}`;
    return this.httpService.get(url).map(res => res.json());
  }
}
